/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __INPUT_HARD_DIRECTX8_MOUSE_H__
#define __INPUT_HARD_DIRECTX8_MOUSE_H__

#include <input/hard/Hardware.h>
#include <input/Manager.h>
#include <NoCopy.h>
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#include <deque>
#include <math/Vector3.h>

namespace liba
{
namespace input
{
namespace hard
{
namespace directx8
{

class Mouse : public Hardware, private Nocopy
{
public:
	Mouse( IDirectInputDevice8 * device, const std::string & name );
	virtual ~Mouse();

	virtual std::string get_name()const;
	virtual Atom get_type()const
	{
		return Manager::mouse_type_name;
	}

	void poll( int ms_count );

	virtual double get_axis_position( const std::string & axis_name )const;
	virtual Manager::AxisType get_axis_type( const std::string & axis_name )const;

	bool is_valid()const
	{
		return valid;
	}

private:
	IDirectInputDevice8 * device;
	std::string name;

	bool valid;

	bool buttons[8];	
	
	std::deque< math::Vector3<float> > accumulate_buffer;
	threads::Mutex poll_lock;	//poll modifies accumulate buffer
};

} // namespace directx8
} // namespace hard
} // namespace input
} // namespace liba
using namespace liba;

#endif //__INPUT_HARD_DIRECTX8_MOUSE_H__
